/************************************************
  * 描述: 测试数据【结构声明】
  * File: testdata.h
  * Author: qijiangyong@mozihealthcare.cn
  * Date: 2025-09-01
  * Update:
  ***********************************************/

#ifndef TESTDATA_H
#define TESTDATA_H

#include <iostream>
#include <optional>
#include <QString>
#include <QDateTime>
#include <QDebug>
#include <common/xlist.hpp>

namespace serialize_data
{
	struct StQtData
	{
		qint64 size;
		qint32 num;
		quint8 type;

		qreal score;

		QString desc;
		std::optional<QDateTime> date; // 可选字段

		xlist::XList<int> lsdata;

		QVariant var;

		void print()
		{
			qDebug() << "size: " << size;
			qDebug() << "num: " << num;
			qDebug() << "type: " << type;

			qDebug() << "score: " << score;

			qDebug() << "desc: " << desc;

			if (date.has_value()) {
				qDebug() << "date: " << date.value().toString("yyyy-MM-dd HH:mm:ss");
			} else {
				qDebug() << "date: (none)";
			}

			lsdata.printByQt();

			qDebug() << "variant:" << var;
		}

		bool operator==(const StQtData& other) const
		{
			return (size == other.size) && (num == other.num) &&
					(type == other.type) && qFuzzyCompare(score, other.score) &&
					(0 == desc.compare(other.desc)) && (date == other.date) &&
					(lsdata.ToList() == other.lsdata.ToList()) && (var == other.var);
		}

		bool operator!=(const StQtData& other) const
		{
			return !(*this == other);
		}
	};

	struct StTest
	{
		qint32 nnn;
		qreal fff;
		QString sss;

		void print()
		{
			qDebug() << "int:" << nnn;
			qDebug() << "float:" << fff;
			qDebug() << "string:" << sss;
		}
	};

	struct UploadResultData
	{
		/**
		 * 文件Id
		 */
		QString fileId;
	};
	struct UploadResult
	{
		/**
		 * true成功/false失败
		 */
		bool success;
		/**
		 * 结果标识
		 */
		int code;
		/**
		 * 结果描述
		 */
		QString msg;
		/**
		 * 结果数据
		 */
		std::optional<UploadResultData> data;

		void print()
		{
			qDebug() << "success:" << (success ? "true" : "false");
			qDebug() << "code:" << code;
			qDebug() << "msg:" << msg;
			qDebug() << "data:" << (data.has_value() ? data.value().fileId : "null");
		}
	};
}
Q_DECLARE_METATYPE(serialize_data::StQtData)

#endif //TESTDATA_H
